<?php
class Admin_Form_AddRegionDestination extends Apps_Form {
	public function init() {
		$dataMaper 	= new M_Tool_DataMapper();
		
		$tbcountry = new M_DbTable_Country();
		$country   = new Zend_Form_Element_Select(
				'country_id',
				array('label'        => 'Country',
						'required'	 => true,
						'RegisterInArrayValidator' => false,
						'attribs'      => array('class'                     => 'chainselect input-medium',
								'data-chainselect-source'   => '/admin/index/ajax?ajax=list-area-destination',
								'data-chainselect-target'   => '[data-chainselect-selector=\'area-1\']'),
						'multiOptions' => $dataMaper->mapKeyValue(
								new M_DbTable_Country(),
								'id',
								'en_name',
								array('' => 'Country')
						)
				));
		
		$tbArea = new M_DbTable_AreaDestination();
		$area   = new Zend_Form_Element_Select(
				'area_destination_id',
				array(
						'label'    => 'Area destination',
						'RegisterInArrayValidator' => false,
						'attribs'  => array(
								'class'	                    => 'input-medium',
								'data-chainselect-selector' => 'area-1',
						),
						'multiOptions' => ($this->_request->getActionName() == 'edit')
						? $dataMaper->mapKeyValue(
								new M_DbTable_AreaDestination(),
								'id',
								'en_name')
						: array('' => 'Area')
				)
		);

		$title = new Zend_Form_Element_Text(
				'name',
				array('label' 		=> 'Region name (Vi)',
						'filters'		=> array('StringTrim')));

		$enTitle = new Zend_Form_Element_Text(
				'en_name',
				array('label' 		=> 'Region name (En)',
					  'required'	=> true,
						'filters'		=> array('StringTrim')));

		$description = new Zend_Form_Element_Textarea(
				'description',
				array('label' => 'Description',
					  'rows'	=> 2,
					  'cols'	=> 80));

		$sortingNumber = new Zend_Form_Element_Text(
				'sorting_number',
				array('label'      => 'Sorting number',
						'class'      => 'input-mini'));
		
		$this->setLegend('Add New');
		$this->addElement($country)
			 ->addElement($area)
			 ->addElement($enTitle)
			 ->addElement($title)
			 ->addElement($sortingNumber)
			 ->addElement($description);

		$this->addActionGroup()
			 ->makeup();
	}
}